<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <script src="../lib/vue2.js"></script>
  </head>
  <body>
    <div id="box">
      <!-- 通过管道符 | 对数据进行加工 -->
      {{name|filter1|filter2}}
    </div>

    <script>
      // 注册全局过滤器
      Vue.filter("filter1", (item) => {
        return item.substring(0, 1).toUpperCase() + item.substring(1);
      });
      Vue.filter("filter2", (item) => {
        return item + ".Ivanov";
      });

      let vm = new Vue({
        el: "#box",
        data: {
          name: "zhangsan",
        },
      });
    </script>
  </body>
</html>
